package com.sunjob.mroresource.controller;

import com.sunjob.common.domain.resource.ToolEntity;
import com.sunjob.common.result.Result;
import com.sunjob.mroresource.service.ToolService;
import io.swagger.annotations.Api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "工具管理")
@RequestMapping("/tool")
public class ToolController {
    @Autowired
    private ToolService toolService;

    //工具的新增
    @RequestMapping("addtool")
    public int addTool(ToolEntity toolEntity){

        return toolService.addTool(toolEntity);
    }
    //查询工具
    @RequestMapping("listtool")
    public Object listTool(){
        return toolService.listTool();
    }
    //修改工具状态
    @RequestMapping("uqdateTool")
    public Result<Integer> uqdatetool(@RequestParam("") long id){
        int xiug = toolService.uqdatetool(id);
        if (xiug == 0){
            return Result.fail("修改工具数据失败！");
        }
        return  com.sunjob.common.result.Result.ok(xiug,"修改工具数据成功！");
    }
    //根据工具id查找工具
    @RequestMapping("listtoolid")
    public List<ToolEntity> listToolId(ToolEntity toolEntity){

        return toolService.listtoolId(toolEntity);
    }
    //根据工具型号查找工具
    @RequestMapping("listtoolname")
    public List<ToolEntity> listToolName(ToolEntity toolEntity){

        return toolService.listtoolname(toolEntity);
    }
    //根据工具型号查找工具
    @RequestMapping("listtoolmodel")
    public List<ToolEntity> listtoolModel(ToolEntity toolEntity){

        return toolService.listtoolmodel(toolEntity);
    }
    //根据工具仓库区查找工具
    @RequestMapping("listtoolstorearea")
    public Object listtoolStorearea(){

        return toolService.listtoolstorearea();
    }
    //根据厂家查找
    @RequestMapping("listtoolvender")
    public Object listtoolVender(){

        return toolService.listtoolvender();
    }
    //根据产地查找
    @RequestMapping("listtoolarea")
    public Object listtoolArea(){

        return toolService.listtoolarea();
    }
    //根据工具种类id查找
    @RequestMapping("listtoolspecies")
    public Object listtoolSpecies_id(){

        return toolService.listtoolspecies_id();
    }
    //根据适用车型查找
    @RequestMapping("listtoolVehicletype")
    public Object listtoolvehicletype(){
        return toolService.listtoolvehicletype();
    }
    /*//删除工具
    @RequestMapping("deleteTool")
    public List<ToolEntity> deletetool(ToolEntity toolEntity){

        return toolService.deletetool(toolEntity);
    }*/

}
